package com.yunnuo.system.comm.entity;

import org.hibernate.annotations.GenericGenerator;

import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;

/**
 * Created by w_weihf on 2018/7/20.
 */
@MappedSuperclass
public class IdEntity {


    private static final long serialVersionUID = 1L;

    private String id;

    /**
     * 更新实体对象需要更新的属性，在service层调用该方法进行更新
     *
     * @param vo
     */
    public void setVO(IdEntity vo){

    }

    @Id
    // @GeneratedValue(strategy = GenerationType.IDENTITY)
    // @GeneratedValue(strategy = GenerationType.SEQUENCE)
    // @GeneratedValue(strategy=GenerationType.AUTO,generator="uuid-string")
    @GeneratedValue(generator = "system-uuid")
    @GenericGenerator(name = "system-uuid", strategy = "uuid")
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    /*
     * 覆盖对象比较的方法 (non-Javadoc)
     *
     * @see java.lang.Object#equals(java.lang.Object)
     */
    @Override
    public boolean equals(Object orther) {
        if(orther == null){
            return false;
        }
        if(orther.getClass() != this.getClass()){
            return false;
        }
        final IdEntity ob = (IdEntity) orther;
        if (this.id == null || !this.id.equals(ob.getId()))
            return false;
        return true;
    }

   @Override
    public int hashCode() {
        int result;
        result = this.id == null ? new String("").hashCode() : this.id.hashCode();
        result = 29 * result;
        return result;
    }
}
